/*
 * @Author: HeAo
 * @Date: 2022-09-14 09:29:14
 * @LastEditTime: 2022-09-15 09:11:05
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \第二阶段\ES6\day02\1-数组解构.js
 * 别乱动！
 */
// 一、数组解构
// 1、完全解构
// let [a, b, c, d, e] = [1, 2, 3, 4]
// console.log(a, b, c, d, e); //1 2 3 4 undefined

// let [a, b, c, d, e] = [1, 2, 3, [4, 5], 6]
// console.log(a, b, c, d, e); //1 2 3 [ 4, 5 ] 6

// 2、不完全解构 数组嵌套数组，[d]个数<[4,5,6]
// let [a, b, c, [d], e] = [1, 2, 3, [4, 5, 6], 7]
// console.log(a, b, c, [d], e); //1 2 3 [ 4 ] 7

// 3、默认值解构 当右侧的数组是空数组时，默认值解构才生效
// let [a = 1, b = 2, c = 3] = [4, 5, 6]
// console.log(a, b, c); //4 5 6

// let [a = 1, b = 2, c = 3] = []
// console.log(a, b, c); //1 2 3

// let test = () => {
//   console.log('我是箭头函数');
//   return 0
// }
// let [a = test()] = [1]
// console.log(a); //1
// let [a = test()] = []
// console.log(a); //我是箭头函数 0

// 4、集合解构
let [a, ...b] = [1, 2, 3, 4]
console.log(a, b); //1 [ 2, 3, 4 ]

// 5、拓展运算符
let [...arr] = [1, 2, 3, 4, 5]
console.log(arr); //[ 1, 2, 3, 4, 5 ]